package redisLearning;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.List;

public class redisStringDemo {

    public static void test1(Jedis jedis) {
        jedis.flushAll();

        jedis.mset("key1", "111", "key2", "222", "key3", "333");
        List<String> values = jedis.mget("key1", "key2", "key100","key3");
        System.out.println("values:" + values);
        jedis.set("key11", "asfdsadfasf");
        String str = jedis.getrange("key11", 1,-1);
        System.out.println(str);
        jedis.setrange("key11", 1,"zzzzzzzzzzzzzzzzz");
        System.out.println(jedis.get("key11"));

        jedis.append("key11", "qqq");
        System.out.println(jedis.get("key11"));

        jedis.set("key22", "12");
        jedis.incr("key22");
        System.out.println(jedis.get("key22"));
        jedis.incrBy("key22", -2);
        System.out.println(jedis.get("key22"));


    }

    public static void main(String[] args) {
        JedisPool jedisPool = new JedisPool("tcp://127.0.0.1:8888");
        try(Jedis jedis = jedisPool.getResource()) {
            test1(jedis);
        }
    }
}
